package org.example;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class DBUtil {
    private static SessionFactory sf=null;
    public static SessionFactory getSessionFactory(){
        Session session=null;
        if(sf==null){
            //创建Hibernate核心类
            Configuration cfg=new Configuration();
            //读取核心配置文件
            cfg.configure("hibernate.cfg.xml");
            //创建session工厂
            sf = cfg.buildSessionFactory();
        }
            //session= sf.openSession();

        //获取session

        return sf;
    }

}
